<template>
  <div class="viewcontainer">
    <el-row style="margin: 0 0 10px">
      <el-col :span="20">
        <el-form :model="queryPanel" label-width="80px">
          <el-row>
            <el-col :span="6">
              <el-form-item label="订单号">
                <el-input clearable v-model="queryPanel.app_no"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="产品名称">
                <el-input clearable v-model="queryPanel.app_name"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-col>
      <el-col :span="2" style="text-align: right">
        <el-button type="primary" @click="queryData">查询</el-button>
      </el-col>
    </el-row>

    <el-table
      :data="tableData"
      style="width: 100%"
      height="86%"
      v-loading="loading"
    >
      <el-table-column type="index" width="50" />
      <el-table-column prop="appNo" label="订单号" width="150" />
      <el-table-column prop="appName" label="产品名称" width="150" />
      <el-table-column prop="createDate" label="创建时间" width="220" />
      <el-table-column prop="price" label="订单金额" width="150" />
      <el-table-column prop="orderType" label="订单类型">
        <template slot-scope="scope">
          <div v-if="scope.row.orderType == 0">普通订单</div>
          <div v-else-if="scope.row.orderType == 1">试用订单</div>
          <div v-else>续费订单</div>
        </template>
      </el-table-column>
      <el-table-column prop="fauditpoint" label="状态" width="150">
        <template slot-scope="scope">
          <div v-if="scope.row.fauditpoint == 0">已审核</div>
          <div v-else>未审核</div>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button type="text" size="small">详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      background
      layout="prev, pager, next"
      :total="total"
      :page-size="pageSize"
      :current-page.sync="pageIndex"
      @current-change="currentChange"
    >
    </el-pagination>
  </div>
</template>

<script>
import { getOrder } from "@/service/app";
export default {
  data() {
    return {
      loading: true,
      input1: null,
      tableData: null,
      total: 9999,
      pageSize: 10,
      pageIndex: 1,
      queryPanel: {
        app_no: null,
        app_name: null,
      },
    };
  },
  methods: {
    queryData() {
      getOrder(
        this.queryPanel.app_no,
        this.queryPanel.app_name,
        this.pageIndex,
        this.pageSize
      ).then((res) => {
        this.tableData = res.rows;
        this.total = res.total;
        if (this.tableData) {
          this.loading = false;
        }
        setTimeout(() => {
          this.loading = false;
        }, 10000);
      });
    },
    currentChange(newpage) {
      this.pageIndex = newpage;
      // queryData();
      this.queryData();
    },
  },

  created() {
    this.queryData();
    this.loading = true;
  },
};
</script>

<style rel ="stylesheet/scss" lang="scss" scoped>
.viewcontainer {
  width: 100%;
  height: calc(100vh - 84px);
  background: #fff;
}
</style>